package com.ruoyi.consume.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.consume.mapper.PesticideApplyConMapper;
import com.ruoyi.consume.domain.PesticideApplyCon;
import com.ruoyi.consume.service.IPesticideApplyConService;

/**
 * 农药领用Service业务层处理
 *
 * @author ruoyi
 * @date 2021-07-23
 */
@Service
public class PesticideApplyConServiceImpl implements IPesticideApplyConService
{
    @Autowired
    private PesticideApplyConMapper pesticideApplyConMapper;

    /**
     * 查询农药领用
     *
     * @param pesticideApplyId 农药领用ID
     * @return 农药领用
     */
    @Override
    public PesticideApplyCon selectPesticideApplyById(Long pesticideApplyId)
    {
        return pesticideApplyConMapper.selectPesticideApplyById(pesticideApplyId);
    }

    /**
     * 查询农药领用列表
     *
     * @param pesticideApplyCon 农药领用
     * @return 农药领用
     */
    @Override
    public List<PesticideApplyCon> selectPesticideApplyList(PesticideApplyCon pesticideApplyCon)
    {
        return pesticideApplyConMapper.selectPesticideApplyList(pesticideApplyCon);
    }

    /**
     * 新增农药领用
     *
     * @param pesticideApplyCon 农药领用
     * @return 结果
     */
    @Override
    public int insertPesticideApply(PesticideApplyCon pesticideApplyCon)
    {
        pesticideApplyCon.setCreateTime(DateUtils.getNowDate());
        return pesticideApplyConMapper.insertPesticideApply(pesticideApplyCon);
    }

    /**
     * 修改农药领用
     *
     * @param pesticideApplyCon 农药领用
     * @return 结果
     */
    @Override
    public int updatePesticideApply(PesticideApplyCon pesticideApplyCon)
    {
        pesticideApplyCon.setUpdateTime(DateUtils.getNowDate());
        return pesticideApplyConMapper.updatePesticideApply(pesticideApplyCon);
    }

    /**
     * 批量删除农药领用
     *
     * @param pesticideApplyIds 需要删除的农药领用ID
     * @return 结果
     */
    @Override
    public int deletePesticideApplyByIds(Long[] pesticideApplyIds)
    {
        return pesticideApplyConMapper.deletePesticideApplyByIds(pesticideApplyIds);
    }

    /**
     * 删除农药领用信息
     *
     * @param pesticideApplyId 农药领用ID
     * @return 结果
     */
    @Override
    public int deletePesticideApplyById(Long pesticideApplyId)
    {
        return pesticideApplyConMapper.deletePesticideApplyById(pesticideApplyId);
    }

    /**
     * 更新库存量表
     *
     * @param pesticideApplyCon 农药领用ID
     * @return 结果
     */
    public int updatePesticideAmount(PesticideApplyCon pesticideApplyCon){
        return pesticideApplyConMapper.updatePesticideAmount(pesticideApplyCon);
    }

    /**
     * 更新领用状态
     *
     * @param pesticideApplyId 农药领用ID
     * @return 结果
     */
    public int updateConsumeStatus(Long pesticideApplyId){
        return pesticideApplyConMapper.updateConsumeStatus(pesticideApplyId);
    }

    /**
     * 退回操作
     *
     * @param pesticideApplyId 农药领用ID
     * @return 结果
     */
    public int updateApprovalStatus(Long pesticideApplyId){
        return pesticideApplyConMapper.updateApprovalStatus(pesticideApplyId);
    }
}
